package com.yz.house.ui.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jaeger.library.StatusBarUtil;
import com.yz.house.R;
import com.yz.house.base.BaseActivity;
import com.yz.house.model.AboutProductsBean;
import com.yz.house.model.ContentBean;
import com.yz.house.model.DecorateBean;
import com.yz.house.ui.adaper.AboutProductsAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Demo
 *
 * @author zhangyf
 * @date 2018/4/13 0013.
 */
public class ContentDetailActivity extends BaseActivity {

    @BindView(R.id.rv_content)
    RecyclerView rv_content;
    @BindView(R.id.backdrop)
    ImageView backdrop;
    AboutProductsAdapter adapter;
    List<AboutProductsBean> data;
    String img;
    String content;
    View head;
    TextView tvContent;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_content_detail;
    }

    @Override
    protected void initVariables(Bundle extras, Bundle savedInstanceState) {
        img = extras.getString("img");
        content = extras.getString("content");
        data = new ArrayList<>();
        data.add(new AboutProductsBean("ZARASHIhome 金属篮筐","￥156-299",R.mipmap.img_more_prd1));
        data.add(new AboutProductsBean("Zara Home 金属夹衣架（2 件套）","￥89",R.mipmap.img_more_prd2));
    }

    @Override
    protected void initViews() {
        StatusBarUtil.setTranslucent(this);
        StatusBarUtil.setTranslucentForCoordinatorLayout(this, 80);
        adapter = new AboutProductsAdapter(data);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                readyGo(GoodsDetailActivity.class);
            }
        });
        rv_content.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        head = LayoutInflater.from(this).inflate(R.layout.layout_content, rv_content, false);
        tvContent = head.findViewById(R.id.tv_content);
        tvContent.setText(content);
        Glide.with(this).load(img).into(backdrop);
        adapter.addHeaderView(head);
        rv_content.setAdapter(adapter);
    }

    @Override
    protected boolean shouldBindEvent() {
        return false;
    }


    @OnClick({R.id.iv_back, R.id.iv_share})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                onBackPressed();
                break;
            case R.id.iv_share:
                break;
        }
    }
}
